package com.linkhouse.interfaces;

import com.linkhouse.domain.po.TbOldRoom;
import com.linkhouse.mapper.TbOldRoomESMapper;
import com.linkhouse.mapper.TbOldRoomMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
import org.springframework.data.elasticsearch.core.SearchHit;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("oldRoom")
@RefreshScope //开启自动刷新配置
public class TbOldRoomInterfaces {
    @Autowired
    private TbOldRoomMapper           tbOldRoomMapper;
    @Autowired
    private ElasticsearchRestTemplate elasticsearchRestTemplate;
    @Autowired
    private TbOldRoomESMapper         tbOldRoomESMapper;
    //用户户位置
    @GetMapping
    public List<TbOldRoom> query(String roomAddr){
        roomAddr = "北京";
        List<SearchHit<TbOldRoom>> byRoomAddr = tbOldRoomESMapper.findByRoomAddr(roomAddr);
        byRoomAddr.forEach(System.err::println);
        return tbOldRoomMapper.selectList(null);
    }

}
